import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-03-18
 * Time: 13:55
 */
public class test2 {
    /**
     * 两数之和
     */

    public int[] twoSum(int[] nums, int target) {
        Map<Integer,Integer> hash = new HashMap<>();
        for(int i=0;i<nums.length;i++){
            if(hash.containsKey(target-nums[i])){
                return new int[]{i,hash.get(target-nums[i])};
            }
            hash.put(nums[i],i);
        }
        return new int[0];
    }
}
